package cn.wolfcode.luowowo.comment.domain;

import cn.wolfcode.luowowo.comment.vo.AttractionCommentVo;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.lang3.StringUtils;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 攻略评论
 */
@Setter
@Getter
@Document("attraction_comment")   //文档所在集合名字
public class AttractionComment implements Serializable {
    @Id
    private String id;  //spring - data 默认封装成 ObjectId
    private Long attrId;  //景点id
    private String attrTitle; //景点标题

    private String firstCommentUrl;//评论的第一张照片
    private Long userId;    //用户id
    private String username;  //用户名
    private String city;
    private int level;
    private String headUrl;     //头像

    private AttractionCommentVo attractionCommentVo;//和点评数的vo对象
    private long relynum = 0;

    private int star; //评论星级
    private Date createTime;    //创建时间
    private String content;      //评论内容
    private String commentUrl; //评论图片

    private List<Map<String,Object>> replay = new ArrayList<>(); //回复对象

    public List<String> getCommentUrl(){
        List<String> list = null ;
        if(StringUtils.isNotBlank(commentUrl)){
            String[] strs = commentUrl.split(",");
            list = new ArrayList<>();
            for (int i = 0; i <strs.length ; i++) {
                list.add(strs[i]);
            }
        }
        return  list;
    }

    /*
    * {
         form:{AttractionComment}
         to:{AttractionComment}
         content:xxx
          Date createTime; //创建时间
     }

    *
    * */

}
